<template>
  <div>
    <MyTable
      :list="list"
      @fn="fn"
    ></MyTable>
    <MyDetail v-if="edit" @close="close" :newList="newList"></MyDetail>
  </div>
</template>

<script>
import MyTable from "./components/MyTable";
import MyDetail from "./components/MyDetail";
export default {
  components: {
    MyTable,
    MyDetail,
  },
  methods: {
    fn(doctor) {
      this.edit = true;
      this.newList = this.list.filter((item) => item.doctor === doctor);
    },
    close() {
      this.edit = false;
    },
  },
  data() {
    return {
      edit: false,
      newList: [],
      list: [
        {
          date: "2022-01-01",
          doctor: "张三",
          diagnosis: "感冒",
          prescription: "感冒药",
        },
        {
          date: "2022-02-01",
          doctor: "李四",
          diagnosis: "头疼",
          prescription: "止疼药",
        },
        {
          date: "2022-03-01",
          doctor: "王五",
          diagnosis: "腰痛",
          prescription: "止痛贴",
        },
      ],
    };
  },
};
</script>

<style></style>
